﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ResetRCSModules.CCApResetRCSModulesEnabler
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Collections.ObjectModel;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.ResetRCSModules;

internal class CCApResetRCSModulesEnabler : ITxCommandEnabler
{
  private bool IsSimulationRunning
  {
    get => TxApplication.ActiveDocument.SimulationPlayer.IsSimulationRunning();
  }

  public bool Enable => this.ShouldEnable() && !this.IsSimulationRunning;

  private bool ShouldEnable()
  {
    bool flag = false;
    TxObjectList allItems = TxApplication.ActiveSelection.GetAllItems();
    if (((Collection<ITxObject>) allItems).Count == 1)
    {
      TxRobot txRobot = ((Collection<ITxObject>) allItems)[0] as TxRobot;
      if (TxRobot.op_Inequality(txRobot, (ITxObject) null))
      {
        TxRobotController controller = txRobot.Controller;
        if (controller.Name != "default" && controller is TxRobotRRSController)
          flag = true;
      }
    }
    return flag;
  }
}
